package com.homework.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class LoginInterceptor extends AbstractInterceptor {
	private static final long serialVersionUID = 1L;

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		ActionContext cxt = invocation.getInvocationContext();
		Map map = cxt.getSession();
		Object obj = map.get("user");
		if (obj == null) {
			return Action.INPUT;
		}
		return invocation.invoke();
	}
}
